/**
 * @function namespace/signatrue - Component type : Control type : Parser.formskin : Parser.impl : html
 * conf - configuration properties for layout
 * prop - properties
 * parentconf - parent element conf
 * parentprop - parent element prop
 */
Parser["control:dhxgrid:default:Json2htmlParser:html"] = function(confs) {
	Parser.log("Processing Parser control:dhxgrid:default:Json2htmlParser:html");
	var conf = confs[0];
	var prop = conf.id ? Parser.props[conf.id] : {};
	Parser.log("conf="+JSON.stringify(conf));
	Parser.log("prop="+JSON.stringify(prop));
	Parser.generatedscript += '\n\n';
	
	//metadata
	if (prop.gridsetting && prop.gridsetting.length>0) {
		for (var i in prop.gridsetting) {
			if ("dataprovider-dict"==prop.gridsetting[i].meta) {
				Parser.generatedscript += 'fmdv.dataprovider["'+prop.gridsetting[i].metasource.type.toUpperCase()+'"]={"rtn":"enu","dp":"dict","type":"'+prop.gridsetting[i].metasource.type.toUpperCase()+'","target":"BPM"};\n';
			} else if ("dataprovider-restsrv"==prop.gridsetting[i].meta) {
				Parser.generatedscript += 'fmdv.dataprovider["'+prop.gridsetting[i].metasource.realValue+'"]={"rtn":"enu","dp":"svc","svcid":"'+prop.gridsetting[i].metasource.realValue+'","intfvars":'+(prop.gridsetting[i].metasource.intfvars?JSON.stringify(prop.gridsetting[i].metasource.intfvars):"null")+'};\n';
			}
		}
	}
	//functions
	Parser.generatedscript += 'fmdv.ui["'+conf.id+'"] = {};\n';
	Parser.generatedscript += 'fmdv.ui["'+conf.id+'"].getData = function(piId) {\n';
	Parser.generatedscript += '	var uiid = "'+conf.id+'";\n';
	Parser.generatedscript += '	var uiidg = uiid+"_grid";\n';
	Parser.generatedscript += '	var editable = '+(prop.editable=='1'?'true':'false')+';\n';
	Parser.generatedscript += '	var paging = '+(prop.paging=='1'?'true':'false')+';\n';
	Parser.generatedscript += '	var hlChanged = '+(prop.hlChanged=='1'?'true':'false')+';\n';
	Parser.generatedscript += '	var hlChangedColor = "#fffabb";\n';
	Parser.generatedscript += '	var model = "'+prop.model+'";\n';
	Parser.generatedscript += '	var defaults = {};\n';
	Parser.generatedscript += '	var nc = 0;\n';
	Parser.generatedscript += '	var gridHeight = 147;\n';
	Parser.generatedscript += '	var columns = ["ITEM_NO_"];\n';
	Parser.generatedscript += '	var dateCols = [];\n';
	Parser.generatedscript += '	var colNames = ["'+fmd_i18n_modules.dhxgrid.sel+'","CHANGED","'+fmd_i18n_modules.dhxgrid.num+'","'+fmd_i18n_modules.dhxgrid.itemno+'"];\n';
	Parser.generatedscript += '	var colWidth = "40,40,40,60";\n';
	Parser.generatedscript += '	var colIds = "_SEL,_CHANGED,_NO,ITEM_NO_";\n';
	Parser.generatedscript += '	var colTypes = "ch,ro,ro,ro";\n';
	Parser.generatedscript += '	var colSorting = "na,na,na,na";\n';
	Parser.generatedscript += '	var colMaxlength = "0,0,0,0";\n';
	Parser.generatedscript += '	var colVisibility = "'+(prop.editable=='1'?'false':'true')+',true,false,true";\n';
	Parser.generatedscript += '	var colAlign = "center,center,center,center";\n';
	Parser.generatedscript += '	var idx_SEL = 0;\n';
	Parser.generatedscript += '	var idx_CHANGED = 1;\n';
	Parser.generatedscript += '	var idx_NO = 2;\n';
	Parser.generatedscript += '	var idx_ITEM_NO = 3;\n';
	Parser.generatedscript += "	var gridsetting = "+(typeof(prop.gridsetting)=='string'?prop.gridsetting:JSON.stringify(prop.gridsetting))+";\n";

	//columns
	if (prop.gridsetting && prop.gridsetting.length>0) {
		for (var i in prop.gridsetting) {
			
			//validation
			var required = Parser.parseSubgridValidator(conf.id, prop.gridsetting[i].id, prop.gridsetting[i].validate);
			
			Parser.generatedscript += '	var idx_'+prop.gridsetting[i].id+'='+(Number(i)+4)+';\n';
			var colId = prop.gridsetting[i].id.toUpperCase();
			Parser.generatedscript += '	columns.push("'+colId.toUpperCase()+'");\n';
			Parser.generatedscript += '	colNames.push("'+(required?"<span class='xh'>*</span>":"")+prop.gridsetting[i][Parser.lang]+'");\n';
			Parser.generatedscript += '	colWidth += ","+"'+prop.gridsetting[i].width+'";\n';
			Parser.generatedscript += '	colIds +=","+"'+prop.gridsetting[i].id.toUpperCase()+'";\n';
			var edt = prop.gridsetting[i].editortype;
			if (prop.gridsetting[i].readonly=='1') {
				if (edt=='ed') {
					edt = 'ro';
				} else if (edt=='coro') {
					edt = 'rocoro';
				} else if (edt=='ch') {
					edt = 'roch';
				} else {
					edt = 'ro';
				}
			}
			Parser.generatedscript += '	colTypes += ","+"'+edt+'";\n';
			//Parser.generatedscript += '	colSorting += ","+"'+prop.gridsetting[i].sort+'";\n';
			Parser.generatedscript += '	colSorting += ",na";\n';
			Parser.generatedscript += '	colVisibility += ","+"'+(prop.gridsetting[i].hidden=='0'?'false':'true')+'";\n';
			Parser.generatedscript += '	colAlign += ","+"'+prop.gridsetting[i].align+'";\n';
			if (prop.gridsetting[i]["default"]!=undefined && prop.gridsetting[i]["default"]!='') {
				if ('string'==prop.gridsetting[i].type || 'datetime'==prop.gridsetting[i].type || 'text'==prop.gridsetting[i].type) {
					Parser.generatedscript += '	defaults[idx_'+prop.gridsetting[i].id+'] = "'+prop.gridsetting[i]["default"]+'";\n';
				} else if ('int'==prop.gridsetting[i].type || 'number'==prop.gridsetting[i].type) {
					Parser.generatedscript += '	defaults[idx_'+prop.gridsetting[i].id+'] = '+prop.gridsetting[i]["default"]+';\n';
				}
			}
			if ('datetime'==prop.gridsetting[i].type && prop.gridsetting[i].readonly!='1') {
				Parser.generatedscript += '	dateCols.push("'+colId+'");\n';
			}
			//maxlength
			var maxlength = prop.gridsetting[i].maxlength ? prop.gridsetting[i].maxlength : "0";
			Parser.generatedscript += '	colMaxlength += ","+"'+maxlength+'";\n';
		}
	}
	//grid
	Parser.generatedscript += '	$("#"+uiidg).css({"minHeight":gridHeight});\n';
	Parser.generatedscript += '	new dhtmlXToolbarObject(uiid+"_sb");\n';
	Parser.generatedscript += '	fmdv.ui[uiidg] = new dhtmlXGridObject(uiidg);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setIconsPath(imagepath);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setHeader(colNames);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setInitWidths(colWidth);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColumnIds(colIds);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColTypes(colTypes);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColSorting(colSorting);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColMaxlength && fmdv.ui[uiidg].setColMaxlength(colMaxlength);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColumnsVisibility(colVisibility);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColAlign(colAlign);\n';
	//Parser.generatedscript += '	fmdv.ui[uiidg].setEditable(editable);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setEditable(true);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].enableEditEvents(true,true);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setLang(lang);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setDateFormat("%Y-%m-%d");\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].dateCols=dateCols;\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].init();\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].enableAlterCss("even_row","odd_row");\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].enableAutoHeight(true);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].entBox.onselectstart=function(e){\n';
	Parser.generatedscript += '	    (e||window.event).cancelBubble=true;if(!window.event) e.stopPropagation();return true;\n';
	Parser.generatedscript += '	};\n';
	
	Parser.generatedscript += '	fmdv.ui[uiidg].gridHeight=gridHeight;\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].hlChanged=hlChanged;\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].hlChangedColor=hlChangedColor;\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].idx_CHANGED=idx_CHANGED;\n';
	
	Parser.generatedscript += '	$("#"+uiidg+" .objbox").css({"minHeight": fmdv.ui[uiidg].gridHeight -40});\n';
	
	//bind combo
	if (prop.gridsetting && prop.gridsetting.length>0) {
		for (var i in prop.gridsetting) {
			if ("dataprovider-dict"==prop.gridsetting[i].meta) {
				Parser.generatedscript += '	fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+'=datactx.m.enu["'+prop.gridsetting[i].metasource.type.toUpperCase()+'"];\n';
				Parser.generatedscript += '	fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+'.unshift(["",""]);\n';
				var options = "null";
				if (prop.gridsetting[i].readonly=='1') {
					options = '{"readonly":true}';
				}
				Parser.generatedscript += '	fmdv.ui[uiidg].grid_bindColCombo(idx_'+prop.gridsetting[i].id+',fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+', '+options+');\n';
			} else if ("dataprovider-restsrv"==prop.gridsetting[i].meta) {
				Parser.generatedscript += '	fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+'=datactx.m.enu["'+prop.gridsetting[i].metasource.realValue+'"];\n';
				Parser.generatedscript += '	fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+'.unshift(["",""]);\n';
				var options = "null";
				if (prop.gridsetting[i].readonly=='1') {
					options = '{"readonly":true}';
				}
				Parser.generatedscript += '	fmdv.ui[uiidg].grid_bindColCombo(idx_'+prop.gridsetting[i].id+',fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+', '+options+');\n';
			}
		}
	}
	
	Parser.generatedscript += '	fmdv.ui[uiidg]._grid_ordercolumns = [{"ITEM_NO_":"ASC"}];\n';
	Parser.generatedscript += '	if (paging) {\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].setPagingWTMode(true,true,true,[10,20,50]);\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].enablePaging(true,10,5,uiid+"_sb");\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].setPagingSkin("toolbar", dhx_skin);\n';
	//Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onHeaderClick", grid_onHeaderClick);\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onBeforePageChanged", function(ind,count){fmdv.ui[uiidg].editStop();return true;});\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onPageChanged", function(ind,fInd,lInd){fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults);});\n';
	Parser.generatedscript += '	}\n';
	//Parser.generatedscript += '	fmdv.ui[uiidg].attachEvent("onAfterSorting", function(){$("#"+uiidg).css("height", gridHeight);$("#"+uiidg+" .objbox").css("height", fmdv.ui[uiidg].gridHeight -40);this.resetCounter(idx_NO);});\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].attachEvent("onResizeEnd", function(obj){$("#"+uiidg).css({"minHeight":gridHeight});$("#"+uiidg+" .objbox").css({"minHeight": fmdv.ui[uiidg].gridHeight -40});});\n';
//	Parser.generatedscript += '	fmdv.ui[uiidg].attachEvent("onEditCell", function(stage,rId,cInd,nv,ov){\n';
//	Parser.generatedscript += '		if (cInd==idx_SEL) return true;for (var i in fmdv.ui[uiid].data.rows) {if(fmdv.ui[uiid].data.rows[i].id.toString()==rId) ov=fmdv.ui[uiid].data.rows[i].data[cInd];}\n';
//	Parser.generatedscript += '		if ("ch"==this.getCellExcellType(rId,cInd) && stage==1) {\n';
//	Parser.generatedscript += '			nv = this.cells(rId, cInd).getValue();\n';
//	Parser.generatedscript += '			if (nv!=ov) {this.cells(rId, idx_CHANGED).setValue(1);if(hlChanged){this.setRowColor(rId,hlChangedColor);}var rd = this.getRowData(rId);grid_updateRowData(fmdv.ui[uiid].data, rId, rd);}\n';
//	Parser.generatedscript += '		} else if (stage==2) {\n';
//	Parser.generatedscript += '			nv = this.cells(rId, cInd).getValue();\n';
//	Parser.generatedscript += '			if (nv!=ov) {this.cells(rId, idx_CHANGED).setValue(1);if(hlChanged){this.setRowColor(rId,hlChangedColor);}var rd = this.getRowData(rId);grid_updateRowData(fmdv.ui[uiid].data, rId, rd);}\n';
//	Parser.generatedscript += '		}\n';
//	Parser.generatedscript += '		return true;\n';
//	Parser.generatedscript += '	});\n';
	
	Parser.generatedscript += '	if (editable) {\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onEditCell", function(stage,rId,cInd,nv,ov){\n';
	Parser.generatedscript += '			if (cInd==idx_SEL) return true;\n';
	Parser.generatedscript += '			for (var i in fmdv.ui[uiid].data.rows) {if(fmdv.ui[uiid].data.rows[i].id.toString()==rId) ov=fmdv.ui[uiid].data.rows[i].data[cInd];}\n';
	Parser.generatedscript += '			if ("ch"==this.getCellExcellType(rId,cInd) && stage==1) {\n';
	Parser.generatedscript += '				var nv = this.cells(rId, cInd).getValue();\n';
	Parser.generatedscript += '			} else if (stage==2) {\n';
	Parser.generatedscript += '				var nv = this.cells(rId, cInd).getValue();\n';
	Parser.generatedscript += '			}\n';
	Parser.generatedscript += '			if (nv!=ov) {this.cells(rId, idx_CHANGED).setValue(1);if(hlChanged){this.setRowColor(rId,hlChangedColor);}var rd = this.getRowData(rId);grid_updateRowData(fmdv.ui[uiid].data, rId, rd);}\n';
	Parser.generatedscript += '			return true;\n';
	Parser.generatedscript += '		});\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onCellChanged", function(rId,cInd,nValue){\n';
	//Parser.generatedscript += '			this.cells(rId, idx_CHANGED).setValue(1);if(hlChanged){this.setRowColor(rId,hlChangedColor);}\n';
	Parser.generatedscript += '			if ("ch"==this.getCellExcellType(rId,cInd)) {\n';
	Parser.generatedscript += '				var rd = this.getRowData(rId);grid_updateRowData(fmdv.ui[uiid].data, rId, rd);\n';
	Parser.generatedscript += '			} else {\n';
	Parser.generatedscript += '				var nv = this.cells(rId, cInd).getValue();\n';
	Parser.generatedscript += '			    if (fmdv.ui[uiid].data && fmdv.ui[uiid].data.rows && fmdv.ui[uiid].data.rows.length) {for (var i in fmdv.ui[uiid].data.rows) {if(fmdv.ui[uiid].data.rows[i].id.toString()==rId) fmdv.ui[uiid].data.rows[i].data[cInd]=nv;}}\n';
	Parser.generatedscript += '			}\n';
	Parser.generatedscript += '		});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb").show();\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-all").click(function(){fmdv.ui[uiidg].grid_checkAllInCol(idx_SEL);});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-none").click(function(){fmdv.ui[uiidg].grid_unCheckAllInCol(idx_SEL);});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-rvs").click(function(){fmdv.ui[uiidg].grid_reverseCheckInCol(idx_SEL);});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-del").click(function(){\n';
	Parser.generatedscript += '			var deleted = fmdv.ui[uiidg].grid_deleteChecked(idx_SEL, fmdv.ui[uiid].data);\n';
	Parser.generatedscript += '			if(deleted==undefined){ \n';
	Parser.generatedscript += '				dhtmlx.alert("'+ fmd_i18n_modules.dhxgrid.msg_onSelected +'");\n';
	Parser.generatedscript += '				return false;\n';
	Parser.generatedscript += '			}else{ \n';
	Parser.generatedscript += '				fmdv.ui[uiid].data = grid_filterDhxDataById(fmdv.ui[uiid].data, deleted, idx_NO);\n';
	Parser.generatedscript += '				fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults);\n';
	Parser.generatedscript += '			}\n';
	Parser.generatedscript += '		});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-add").click(function(){\n';
	Parser.generatedscript += '			fmdv.ui[uiidg].editStop();\n';
	Parser.generatedscript += '			var cols = fmdv.ui[uiidg].getColumnsNum();\n';
	Parser.generatedscript += '			!fmdv.ui[uiid].data && (fmdv.ui[uiid].data={"total_count":0, "rows":[]});\n';
	Parser.generatedscript += '			var rid = "n"+nc++, row = {"id": rid, "data":[]};\n';
	Parser.generatedscript += '			for (var i=0;i<cols;i++) {if(i==idx_SEL) {row.data.push(0)} else if(i==idx_CHANGED) {row.data.push(1)} else if(i==idx_NO) {row.data.push(fmdv.ui[uiid].data.rows.length+1)} else {row.data.push(defaults[i]?defaults[i]:"")}}\n';
	Parser.generatedscript += '			fmdv.ui[uiid].data.rows.push(row);\n';
	Parser.generatedscript += '			fmdv.ui[uiid].data.total_count++;\n';
	Parser.generatedscript += '			fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults);\n';
	Parser.generatedscript += '			fmdv.ui[uiidg].toLastPage();\n';
	Parser.generatedscript += '		});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-rst").click(function(){fmdv.ui[uiid].data=null;fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults);});\n';
	Parser.generatedscript += '		fmdv.ui[uiid].saveData = function() {return fmdf.dhxgridSave(piId, uiid, uiidg, model, columns, fmdv.ui["'+conf.id+'"].postGetData);};\n';
	Parser.generatedscript += '	}\n';
	Parser.generatedscript += '	$("#"+uiid+"_tb .btn-grid-import").click(function(){importEx(piId, uiid, uiidg, model, columns,gridsetting, defaults);});\n';
	Parser.generatedscript += '	$("#"+uiid+"_tb .btn-grid-export").click(function(){exportExcel(uiid);});\n';
	Parser.generatedscript += '	$("#"+uiid).trigger("afterinit", fmdv.ui[uiidg]);\n';
	Parser.generatedscript += '	fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults, fmdv.ui["'+conf.id+'"].postGetData);\n';
	Parser.generatedscript += '};\n';
	if (prop.emptyrows) {
		Parser.generatedscript += 'fmdv.ui["'+conf.id+'"].postGetData = function() {\n';
		Parser.generatedscript += '		if ('+(prop.editable=='1'?'true':'false')+"&&"+(prop.paging=='1'?'true':'false')+' && fmdv.ui["'+conf.id+'_grid"].getRowsNum()==0 && '+prop.emptyrows+'>0) {\n';	
		Parser.generatedscript += '	    	for(var i=0;i<'+(prop.emptyrows>10?10:prop.emptyrows)+';i++){\n';
		Parser.generatedscript += '	        	$("#'+conf.id+'_tb .btn-grid-add").trigger("click");\n';
		Parser.generatedscript += '	    	}\n';
		Parser.generatedscript += '		}else{\n';
		Parser.generatedscript += '	    	for(var i=0;i<'+(prop.emptyrows||0)+';i++){\n';
		Parser.generatedscript += '	        	$("#'+conf.id+'_tb .btn-grid-add").trigger("click");\n';
		Parser.generatedscript += '	    	}\n';
		Parser.generatedscript += '     }\n';
		Parser.generatedscript += '	}\n';
	}
		
	/*Parser.generatedscript += "$(document.getElementById('"+conf.id+"')).ready(function(){";
	Parser.generatedscript += "fmdv.ui['"+conf.id+"']=new dhtmlXGridObject('"+conf.id+"');";
	Parser.generatedscript += "fmdv.ui['"+conf.id+"'].setHeader('a,b,c');";
	Parser.generatedscript += "fmdv.ui['"+conf.id+"'].init();";
	Parser.generatedscript += "});\n";*/
	
	var style = Parser.cssDisplay(prop.display)+(prop.style?prop.style:"");
	return '<div id="'+conf.id+'"'+
				(style ? ' style="'+style+'"' : '') +
				'class="gridDiv '+(prop.classNames ? prop.classNames : '')+'"' +
				'>'+
				'<div id="'+conf.id+'_tb" style="display:none;width:100%;">'+
		   		'<div class="btn-toolbar" role="toolbar" style="margin-left:10px;padding-top:10px;margin-bottom:10px;">'+
					'<div class="btn-group" role="group">'+
					  '<button type="button" class="btn btn-default btn-grid-all">'+fmd_i18n_modules.dhxgrid.all+'</button>'+
					  '<button type="button" class="btn btn-default btn-grid-none">'+fmd_i18n_modules.dhxgrid.notall+'</button>'+
					  '<button type="button" class="btn btn-default btn-grid-rvs">'+fmd_i18n_modules.dhxgrid.rvs+'</button>'+
					'</div>'+
					'<div class="btn-group" role="group">'+
					  '<button type="button" class="btn btn-default btn-grid-add">'+fmd_i18n_modules.dhxgrid.add+'</button>'+
					  '<button type="button" class="btn btn-default btn-grid-del">'+fmd_i18n_modules.dhxgrid.del+'</button>'+
					  '<button type="button" class="btn btn-default btn-grid-rst">'+fmd_i18n_modules.dhxgrid.reset+'</button>'+
					'</div>'+			
					'<div class="btn-group excel" role="group"' +(prop.allowImExport =='1' ? '':' style="display:none;"')+' >'+
					'<label for="excelImportFile"><button type="button" class="btn btn-default btn-grid-import">'+fmd_i18n_modules.dhxgrid.importEx+'</button></label>'+
					  '<label><button type="button" class="btn btn-default btn-grid-export">'+fmd_i18n_modules.dhxgrid.exportEx+'</button></label>'+
					'</div>'+
				'</div>'+
		    '</div>'+
		    '<div id="'+conf.id+'_grid" class="form-control table-grid" style="width:100%;height:260px;"></div>'+
		    '<div id="'+conf.id+'_sb" style="width:100%;"></div>'+
			 (prop.attachment=='1' ? '<span class="attachspan" attach-tag="'+(prop.attachmentTag || conf.id)+'">'
								+ (prop.attachmentEditable=='1' ? '<button class="btnupload" title="'+fmd_i18n_prop_upattach+'">&nbsp;'+fmd_i18n_modules.input.attachment+'&nbsp;</button>' : '')
								+ '</span>' : '')+
		'</div>';
};


Parser["control:dhxgrid:bootstrap-blue:Json2htmlParser:html"] = function(confs) {
	Parser.log("Processing Parser control:dhxgrid:bootstrap-blue:Json2htmlParser:html");
	var conf = confs[0];
	var prop = conf.id ? Parser.props[conf.id] : {};
	Parser.log("conf="+JSON.stringify(conf));
	Parser.log("prop="+JSON.stringify(prop));
	Parser.generatedscript += '\n\n';
	
	//metadata
	if (prop.gridsetting && prop.gridsetting.length>0) {
		for (var i in prop.gridsetting) {
			if ("dataprovider-dict"==prop.gridsetting[i].meta) {
				Parser.generatedscript += 'fmdv.dataprovider["'+prop.gridsetting[i].metasource.type.toUpperCase()+'"]={"rtn":"enu","dp":"dict","type":"'+prop.gridsetting[i].metasource.type.toUpperCase()+'","target":"BPM"};\n';
			} else if ("dataprovider-restsrv"==prop.gridsetting[i].meta) {
				Parser.generatedscript += 'fmdv.dataprovider["'+prop.gridsetting[i].metasource.realValue+'"]={"rtn":"enu","dp":"svc","svcid":"'+prop.gridsetting[i].metasource.realValue+'","intfvars":'+(prop.gridsetting[i].metasource.intfvars?JSON.stringify(prop.gridsetting[i].metasource.intfvars):"null")+'};\n';
			}
		}
	}
	//functions
	Parser.generatedscript += 'fmdv.ui["'+conf.id+'"] = {};\n';
	Parser.generatedscript += 'fmdv.ui["'+conf.id+'"].getData = function(piId) {\n';
	Parser.generatedscript += '	var uiid = "'+conf.id+'";\n';
	Parser.generatedscript += '	var uiidg = uiid+"_grid";\n';
	Parser.generatedscript += '	var editable = '+(prop.editable=='1'?'true':'false')+';\n';
	Parser.generatedscript += '	var paging = '+(prop.paging=='1'?'true':'false')+';\n';
	Parser.generatedscript += '	var hlChanged = '+(prop.hlChanged=='1'?'true':'false')+';\n';
	Parser.generatedscript += '	var hlChangedColor = "#fffabb";\n';
	Parser.generatedscript += '	var model = "'+prop.model+'";\n';
	Parser.generatedscript += '	var defaults = {};\n';
	Parser.generatedscript += '	var nc = 0;\n';
	Parser.generatedscript += '	var gridHeight = 147;\n';
	Parser.generatedscript += '	var dateCols = [];\n';
	Parser.generatedscript += '	var columns = ["ITEM_NO_"];\n';
	Parser.generatedscript += '	var colNames = ["'+fmd_i18n_modules.dhxgrid.sel+'","CHANGED","'+fmd_i18n_modules.dhxgrid.num+'","'+fmd_i18n_modules.dhxgrid.itemno+'"];\n';
	Parser.generatedscript += '	var colWidth = "40,40,40,60";\n';
	Parser.generatedscript += '	var colIds = "_SEL,_CHANGED,_NO,ITEM_NO_";\n';
	Parser.generatedscript += '	var colTypes = "ch,ro,ro,ro";\n';
	Parser.generatedscript += '	var colSorting = "na,na,na,na";\n';
	Parser.generatedscript += '	var colMaxlength = "0,0,0,0";\n';
	Parser.generatedscript += '	var colVisibility = "'+(prop.editable=='1'?'false':'true')+',true,false,true";\n';
	Parser.generatedscript += '	var colAlign = "center,center,center,center";\n';
	Parser.generatedscript += '	var idx_SEL = 0;\n';
	Parser.generatedscript += '	var idx_CHANGED = 1;\n';
	Parser.generatedscript += '	var idx_NO = 2;\n';
	Parser.generatedscript += '	var idx_ITEM_NO = 3;\n';
	Parser.generatedscript += "	var gridsetting = "+(typeof(prop.gridsetting)=='string'?prop.gridsetting:JSON.stringify(prop.gridsetting))+";\n";
	//columns
	if (prop.gridsetting && prop.gridsetting.length>0) {
		for (var i in prop.gridsetting) {
			
			//validation
			var required = Parser.parseSubgridValidator(conf.id, prop.gridsetting[i].id, prop.gridsetting[i].validate);
			
			Parser.generatedscript += '	var idx_'+prop.gridsetting[i].id+'='+(Number(i)+4)+';\n';
			var colId = prop.gridsetting[i].id.toUpperCase();
			Parser.generatedscript += '	columns.push("'+colId+'");\n';
			Parser.generatedscript += '	colNames.push("'+(required?"<span class='xh'>*</span>":"")+prop.gridsetting[i][Parser.lang]+'");\n';
			Parser.generatedscript += '	colWidth += ","+"'+prop.gridsetting[i].width+'";\n';
			Parser.generatedscript += '	colIds +=","+"'+prop.gridsetting[i].id.toUpperCase()+'";\n';
			var edt = prop.gridsetting[i].editortype;
			if (prop.gridsetting[i].readonly=='1') {
				if (edt=='ed') {
					edt = 'ro';
				} else if (edt=='coro') {
					edt = 'rocoro';
				} else if (edt=='ch') {
					edt = 'roch';
				}else {
					edt = 'ro';
				}
			}
			Parser.generatedscript += '	colTypes += ","+"'+edt+'";\n';
			//Parser.generatedscript += '	colSorting += ","+"'+prop.gridsetting[i].sort+'";\n';
			Parser.generatedscript += '	colSorting += ",na";\n';
			Parser.generatedscript += '	colVisibility += ","+"'+(prop.gridsetting[i].hidden=='0'?'false':'true')+'";\n';
			Parser.generatedscript += '	colAlign += ","+"'+prop.gridsetting[i].align+'";\n';
			if (prop.gridsetting[i]["default"]!=undefined && prop.gridsetting[i]["default"]!='') {
				if ('string'==prop.gridsetting[i].type || 'datetime'==prop.gridsetting[i].type || 'text'==prop.gridsetting[i].type) {
					Parser.generatedscript += '	defaults[idx_'+prop.gridsetting[i].id+'] = "'+prop.gridsetting[i]["default"]+'";\n';
				} else if ('int'==prop.gridsetting[i].type || 'number'==prop.gridsetting[i].type) {
					Parser.generatedscript += '	defaults[idx_'+prop.gridsetting[i].id+'] = '+prop.gridsetting[i]["default"]+';\n';
				}
			}
			if ('datetime'==prop.gridsetting[i].type && prop.gridsetting[i].readonly!='1') {
				Parser.generatedscript += '	dateCols.push("'+colId+'");\n';
			}
			//maxlength
			var maxlength = prop.gridsetting[i].maxlength ? prop.gridsetting[i].maxlength : "0";
			Parser.generatedscript += '	colMaxlength += ","+"'+maxlength+'";\n';
		}
	}
	//grid
	Parser.generatedscript += '	$("#"+uiidg).css({"minHeight":gridHeight});\n';

	Parser.generatedscript += '	new dhtmlXToolbarObject(uiid+"_sb");\n';
	Parser.generatedscript += '	fmdv.ui[uiidg] = new dhtmlXGridObject(uiidg);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setIconsPath(imagepath);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setHeader(colNames);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setInitWidths(colWidth);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColumnIds(colIds);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColTypes(colTypes);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColSorting(colSorting);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColMaxlength && fmdv.ui[uiidg].setColMaxlength(colMaxlength);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColumnsVisibility(colVisibility);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setColAlign(colAlign);\n';
	//Parser.generatedscript += '	fmdv.ui[uiidg].setEditable(editable);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setEditable(true);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].enableEditEvents(true,true);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setLang(lang);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].setDateFormat("%Y-%m-%d");\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].dateCols=dateCols;\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].init();\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].enableAlterCss("even_row","odd_row");\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].enableAutoHeight(true);\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].entBox.onselectstart=function(e){\n';
	Parser.generatedscript += '	    (e||window.event).cancelBubble=true;if(!window.event) e.stopPropagation();return true;\n';
	Parser.generatedscript += '	};\n';
	
	Parser.generatedscript += '	fmdv.ui[uiidg].gridHeight=gridHeight;\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].hlChanged=hlChanged;\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].hlChangedColor=hlChangedColor;\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].idx_CHANGED=idx_CHANGED;\n';
	
	Parser.generatedscript += '	$("#"+uiidg+" .objbox").css({"minHeight": fmdv.ui[uiidg].gridHeight -40});\n';
	
	//bind combo
	if (prop.gridsetting && prop.gridsetting.length>0) {
		for (var i in prop.gridsetting) {
			if ("dataprovider-dict"==prop.gridsetting[i].meta) {
				Parser.generatedscript += '	fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+'=datactx.m.enu["'+prop.gridsetting[i].metasource.type.toUpperCase()+'"];\n';
				Parser.generatedscript += '	fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+'.unshift(["",""]);\n';
				var options = "null";
				if (prop.gridsetting[i].readonly=='1') {
					options = '{"readonly":true}';
				}
				Parser.generatedscript += '	fmdv.ui[uiidg].grid_bindColCombo(idx_'+prop.gridsetting[i].id+',fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+', '+options+');\n';
			} else if ("dataprovider-restsrv"==prop.gridsetting[i].meta) {
				Parser.generatedscript += '	fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+'=datactx.m.enu["'+prop.gridsetting[i].metasource.realValue+'"];\n';
				Parser.generatedscript += '	fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+'.unshift(["",""]);\n';
				var options = "null";
				if (prop.gridsetting[i].readonly=='1') {
					options = '{"readonly":true}';
				}
				Parser.generatedscript += '	fmdv.ui[uiidg].grid_bindColCombo(idx_'+prop.gridsetting[i].id+',fmdv.ui[uiid].idxComboOps_'+prop.gridsetting[i].id+', '+options+');\n';
			}
		}
	}
	
	Parser.generatedscript += '	fmdv.ui[uiidg]._grid_ordercolumns = [{"ITEM_NO_":"ASC"}];\n';
	Parser.generatedscript += '	if (paging) {\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].setPagingWTMode(true,true,true,[10,20,50]);\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].enablePaging(true,10,5,uiid+"_sb");\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].setPagingSkin("toolbar", dhx_skin);\n';
	//Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onHeaderClick", grid_onHeaderClick);\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onBeforePageChanged", function(ind,count){fmdv.ui[uiidg].editStop();return true;});\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onPageChanged", function(ind,fInd,lInd){fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults);});\n';
	Parser.generatedscript += '	}\n';
	//Parser.generatedscript += '	fmdv.ui[uiidg].attachEvent("onAfterSorting", function(){$("#"+uiidg).css("height", gridHeight);$("#"+uiidg+" .objbox").css("height", fmdv.ui[uiidg].gridHeight -40);this.resetCounter(idx_NO);});\n';
	Parser.generatedscript += '	fmdv.ui[uiidg].attachEvent("onResizeEnd", function(obj){$("#"+uiidg).css({"minHeight":gridHeight});$("#"+uiidg+" .objbox").css({"minHeight": fmdv.ui[uiidg].gridHeight -40});});\n';
	
	Parser.generatedscript += '	if (editable) {\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onEditCell", function(stage,rId,cInd,nv,ov){\n';
	Parser.generatedscript += '			if (cInd==idx_SEL) return true;\n';
	Parser.generatedscript += '			for (var i in fmdv.ui[uiid].data.rows) {if(fmdv.ui[uiid].data.rows[i].id.toString()==rId) ov=fmdv.ui[uiid].data.rows[i].data[cInd];}\n';
	Parser.generatedscript += '			if ("ch"==this.getCellExcellType(rId,cInd) && stage==1) {\n';
	Parser.generatedscript += '				var nv = this.cells(rId, cInd).getValue();\n';
	Parser.generatedscript += '			} else if (stage==2) {\n';
	Parser.generatedscript += '				var nv = this.cells(rId, cInd).getValue();\n';
	Parser.generatedscript += '			}\n';
	Parser.generatedscript += '			if (nv!=ov) {this.cells(rId, idx_CHANGED).setValue(1);if(hlChanged){this.setRowColor(rId,hlChangedColor);}var rd = this.getRowData(rId);grid_updateRowData(fmdv.ui[uiid].data, rId, rd);}\n';
	Parser.generatedscript += '			return true;\n';
	Parser.generatedscript += '		});\n';
	Parser.generatedscript += '		fmdv.ui[uiidg].attachEvent("onCellChanged", function(rId,cInd,nValue){\n';
	//Parser.generatedscript += '			this.cells(rId, idx_CHANGED).setValue(1);if(hlChanged){this.setRowColor(rId,hlChangedColor);}\n';
	Parser.generatedscript += '			if ("ch"==this.getCellExcellType(rId,cInd)) {\n';
	Parser.generatedscript += '				var rd = this.getRowData(rId);grid_updateRowData(fmdv.ui[uiid].data, rId, rd);\n';
	Parser.generatedscript += '			} else {\n';
	Parser.generatedscript += '				var nv = this.cells(rId, cInd).getValue();\n';
	Parser.generatedscript += '			    if (fmdv.ui[uiid].data && fmdv.ui[uiid].data.rows && fmdv.ui[uiid].data.rows.length) {for (var i in fmdv.ui[uiid].data.rows) {if(fmdv.ui[uiid].data.rows[i].id.toString()==rId) fmdv.ui[uiid].data.rows[i].data[cInd]=nv;}}\n';
	Parser.generatedscript += '			}\n';
	Parser.generatedscript += '		});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb").show();\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-all").click(function(){fmdv.ui[uiidg].grid_checkAllInCol(idx_SEL);});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-none").click(function(){fmdv.ui[uiidg].grid_unCheckAllInCol(idx_SEL);});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-rvs").click(function(){fmdv.ui[uiidg].grid_reverseCheckInCol(idx_SEL);});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-del").click(function(){\n';
	Parser.generatedscript += '			var deleted = fmdv.ui[uiidg].grid_deleteChecked(idx_SEL, fmdv.ui[uiid].data);\n';
	Parser.generatedscript += '			if(deleted==undefined){ \n';
	Parser.generatedscript += '				dhtmlx.alert("'+ fmd_i18n_modules.dhxgrid.msg_onSelected +'");\n';
	Parser.generatedscript += '				return false;\n';
	Parser.generatedscript += '			}else{ \n';
	Parser.generatedscript += '				fmdv.ui[uiid].data = grid_filterDhxDataById(fmdv.ui[uiid].data, deleted, idx_NO);\n';
	Parser.generatedscript += '				fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults);\n';
	Parser.generatedscript += '			}\n';
	Parser.generatedscript += '		});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-add").click(function(){\n';
	Parser.generatedscript += '			fmdv.ui[uiidg].editStop();\n';
	Parser.generatedscript += '			var cols = fmdv.ui[uiidg].getColumnsNum();\n';
	Parser.generatedscript += '			!fmdv.ui[uiid].data && (fmdv.ui[uiid].data={"total_count":0, "rows":[]});\n';
	Parser.generatedscript += '			var rid = "n"+nc++, row = {"id": rid, "data":[]};\n';
	Parser.generatedscript += '			for (var i=0;i<cols;i++) {if(i==idx_SEL) {row.data.push(0)} else if(i==idx_CHANGED) {row.data.push(1)} else if(i==idx_NO) {row.data.push(fmdv.ui[uiid].data.rows.length+1)} else {row.data.push(defaults[i]?defaults[i]:"")}}\n';
	Parser.generatedscript += '			fmdv.ui[uiid].data.rows.push(row);\n';
	Parser.generatedscript += '			fmdv.ui[uiid].data.total_count++;\n';
	Parser.generatedscript += '			fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults);\n';
	Parser.generatedscript += '			fmdv.ui[uiidg].toLastPage();\n';
	Parser.generatedscript += '		});\n';
	Parser.generatedscript += '		$("#"+uiid+"_tb .btn-grid-rst").click(function(){fmdv.ui[uiid].data=null;fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults);});\n';
	Parser.generatedscript += '		fmdv.ui[uiid].saveData = function() {return fmdf.dhxgridSave(piId, uiid, uiidg, model, columns);};\n';
	Parser.generatedscript += '	}\n';
	Parser.generatedscript += '	$("#"+uiid+"_tb .btn-grid-import").click(function(){importEx(piId, uiid, uiidg, model, columns,gridsetting, defaults);});\n';
	Parser.generatedscript += '	$("#"+uiid+"_tb .btn-grid-export").click(function(){exportExcel(uiid);});\n';
	Parser.generatedscript += '	$("#"+uiid).trigger("afterinit", fmdv.ui[uiidg]);\n';
	Parser.generatedscript += '	fmdf.dhxgridToPage(piId, uiid, uiidg, model, columns, defaults, fmdv.ui["'+conf.id+'"].postGetData);\n';
	Parser.generatedscript += '};\n';
	if (prop.emptyrows) {
		Parser.generatedscript += 'fmdv.ui["'+conf.id+'"].postGetData = function() {\n';
		Parser.generatedscript += '		if ('+(prop.editable=='1'?'true':'false')+"&&"+(prop.paging=='1'?'true':'false')+' && fmdv.ui["'+conf.id+'_grid"].getRowsNum()==0 && '+prop.emptyrows+'>0) {\n';	
		Parser.generatedscript += '	    	for(var i=0;i<'+(prop.emptyrows>10?10:prop.emptyrows)+';i++){\n';
		Parser.generatedscript += '	        	$("#'+conf.id+'_tb .btn-grid-add").trigger("click");\n';
		Parser.generatedscript += '	    	}\n';
		Parser.generatedscript += '		}else{\n';
		Parser.generatedscript += '	    	for(var i=0;i<'+(prop.emptyrows||0)+';i++){\n';
		Parser.generatedscript += '	        	$("#'+conf.id+'_tb .btn-grid-add").trigger("click");\n';
		Parser.generatedscript += '	    	}\n';
		Parser.generatedscript += '     }\n';
		Parser.generatedscript += '	}\n';
	}
	
	/*Parser.generatedscript += "$(document.getElementById('"+conf.id+"')).ready(function(){";
	Parser.generatedscript += "fmdv.ui['"+conf.id+"']=new dhtmlXGridObject('"+conf.id+"');";
	Parser.generatedscript += "fmdv.ui['"+conf.id+"'].setHeader('a,b,c');";
	Parser.generatedscript += "fmdv.ui['"+conf.id+"'].init();";
	Parser.generatedscript += "});\n";*/
	
	var style = Parser.cssDisplay(prop.display)+(prop.style?prop.style:"");
	return '<div id="'+conf.id+'"'+
				(style ? ' style="'+style+'"' : '') +
				(prop.classNames ? ' class="'+prop.classNames+'"' : '') +
				'>'+
				'<div id="'+conf.id+'_tb" style="display:none;width:100%;">'+
		   		'<div class="btn-toolbar" role="toolbar" style="margin-left:10px;margin-top:-10px;margin-bottom:10px;">'+
					'<div class="btn-group" role="group">'+
					  '<button type="button" class="btn btn-default btn-grid-all">'+fmd_i18n_modules.dhxgrid.all+'</button>'+
					  '<button type="button" class="btn btn-default btn-grid-none">'+fmd_i18n_modules.dhxgrid.notall+'</button>'+
					  '<button type="button" class="btn btn-default btn-grid-rvs">'+fmd_i18n_modules.dhxgrid.rvs+'</button>'+
					'</div>'+
					'<div class="btn-group" role="group">'+
					  '<button type="button" class="btn btn-default btn-grid-add">'+fmd_i18n_modules.dhxgrid.add+'</button>'+
					  '<button type="button" class="btn btn-default btn-grid-del">'+fmd_i18n_modules.dhxgrid.del+'</button>'+
					  '<button type="button" class="btn btn-default btn-grid-rst">'+fmd_i18n_modules.dhxgrid.reset+'</button>'+
					'</div>'+
					'<div class="btn-group excel" role="group"' +(prop.allowImExport =='1' ? '':' style="display:none;"')+' >'+
					'<label for="excelImportFile"><button type="button" class="btn btn-default btn-grid-import">'+fmd_i18n_modules.dhxgrid.importEx+'</button></label>'+
					  '<label><button type="button" class="btn btn-default btn-grid-export">'+fmd_i18n_modules.dhxgrid.exportEx+'</button></label>'+
					'</div>'+
				'</div>'+
		    '</div>'+
		    '<div id="'+conf.id+'_grid" class="form-control" style="width:99%;margin-left: 8px;height:260px;"></div>'+
		    '<div id="'+conf.id+'_sb" style="width:99%;margin-left: 5px;"></div>'
		    + (prop.attachment=='1' ? '<span class="attachspan" attach-tag="'+(prop.attachmentTag || conf.id)+'">'
					+ (prop.attachmentEditable=='1' ? '<button class="btnupload" title="'+fmd_i18n_prop_upattach+'">&nbsp;'+fmd_i18n_modules.input.attachment+'&nbsp;</button>' : '')
					+ '</span>' : '')+
		'</div>';
};

Parser["parseSubgridValidator"] = function(gridId, colId, vv) {
	Parser.log("parseSubgridValidator vv="+JSON.stringify(vv));
	var required = false;
	if (!vv) return required;
	var vc = ''; //validation output content
	//parse gui validation
	if (vv.gui && vv.gui.rows) {
		for (var i in vv.gui.rows) {
			if (vv.gui.rows[i].data[0]=='NotEmpty') {
				required = true;
			}
			vc += 'fmdf.validationsSb["'+gridId+'"]["'+colId+'"].push({inputindex:'+vv.inputindex+',func:function' + vv.gui.rows[i].data[2] + ',c:"' + vv.gui.rows[i].data[1] + '",m:"' + vv.gui.rows[i].data[Parser.lang=='zh'?3:4] + '"});\n';
		}
	}
	//parse custom validation
	if (vv.custom && vv.custom.rows) {
		for (var i in vv.custom.rows) {
			vc += 'fmdf.validationsSb["'+gridId+'"]["'+colId+'"].push({inputindex:'+vv.inputindex+',func:function' + vv.custom.rows[i].data[0] + ',m:"' + vv.custom.rows[i].data[Parser.lang=='zh'?1:2] + '"});\n';
		}
	}
	
	if (vc) {
		Parser.generatedscript += 'fmdf.validationsSb["'+gridId+'"]=fmdf.validationsSb["'+gridId+'"]||{};\n' + 
			'fmdf.validationsSb["'+gridId+'"]["'+colId+'"]=fmdf.validationsSb["'+gridId+'"]["'+colId+'"]||[];\n' + 
			vc;
	}
	
	return required;
};
